//
//  UIColor.swift
//  maopu
//
//  Created by 黄海波 on 2017/4/1.
//  Copyright © 2017年 maopu. All rights reserved.
//

import UIKit

extension UIColor {
    
    class func RGBA(r:CGFloat, g:CGFloat, b:CGFloat, a:CGFloat) -> UIColor{
        return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a)
    }
    
    class func RGB(r:CGFloat, g:CGFloat, b:CGFloat) -> UIColor{
        return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: 1)
    }
    
    class func m_viewBackgroundColor() -> UIColor{
        return RGBA(r: 247, g: 247, b: 247, a: 1)
    }
    
    class func video_bottomViewBgColor() -> UIColor{
        return RGBA(r: 255, g: 255, b: 255, a: 0.1)
    }
    
    class func video_progressTintColor() -> UIColor{
        return UIColor.RGB(r: 129, g: 160, b: 226)
    }
    //    深色文本
    class func m_textDeepColor() -> UIColor{
        return UIColor.RGB(r: 51, g: 51, b: 51)
    }
    
    class func m_102Color() -> UIColor{
        return UIColor.RGB(r: 102, g: 102, b: 102)
    }
    
    class func m_170Color() -> UIColor{
        return UIColor.RGB(r: 170, g: 170, b: 170)
    }
    
    //    浅色文本
    class func m_textLightColor() -> UIColor{
        return UIColor.RGB(r: 164, g: 164, b: 164)
    }
    
    //    浅色文本
    class func m_home_textLightColor() -> UIColor{
        return UIColor.RGB(r: 136, g: 136, b: 136)
    }
    
    //    灰色文本
    class func m_textGrayColor() -> UIColor{
        return UIColor.RGB(r: 194, g: 188, b: 178)
    }
    
    //    标签背景色
    class func m_tagBgColor() -> UIColor{
        return UIColor.RGB(r: 255, g: 79, b: 34)
    }
//    神评论背景色
    class func m_godReplyBgViewColor() -> UIColor{
        return UIColor.RGB(r: 249, g: 249, b: 249)
    }

    
    //    楼主标签背景色
    class func m_landlordBgColor() -> UIColor{
        return UIColor.RGB(r: 255, g: 221, b: 223)
    }
    
    //    楼主文本色
    class func m_landlordTextColor() -> UIColor{
        return UIColor.RGB(r: 247, g: 108, b: 118)
    }
    
    //    头衔背景色
    class func m_rankBgColor() -> UIColor{
        return UIColor.RGB(r: 218, g: 228, b: 255)
    }
    
    //    头衔文本色
    class func m_rankTextColor() -> UIColor{
        return UIColor.RGB(r: 145, g: 133, b: 243)
    }
    
    
    
    class func m_placeholderColor() -> UIColor{
        return UIColor.RGB(r: 199, g: 199, b: 205)
    }
    
    class func m_lineColor() -> UIColor{
        return UIColor.RGB(r: 222, g: 222, b: 222)
    }
    /**
     Make color with hex string
     parameter hex: 16进制字符串
     returns: RGB
     */
    class func colorWithHexString (hex: String) -> UIColor {
        
        var cString: String = hex.uppercased()
        if (cString.hasPrefix("#")) {
            cString = (cString as NSString).substring(from: 1)
        }
        
        if (cString.characters.count != 6) {
            return UIColor.gray
        }
        
        let rString = (cString as NSString).substring(to: 2)
        let gString = ((cString as NSString).substring(from: 2) as NSString).substring(to: 2)
        let bString = ((cString as NSString).substring(from: 4) as NSString).substring(to: 2)
        
        var r:CUnsignedInt = 0, g:CUnsignedInt = 0, b:CUnsignedInt = 0;
        Scanner(string: rString).scanHexInt32(&r)
        Scanner(string: gString).scanHexInt32(&g)
        Scanner(string: bString).scanHexInt32(&b)
        
        return UIColor(red: CGFloat(r) / 255.0, green: CGFloat(g) / 255.0, blue: CGFloat(b) / 255.0, alpha: CGFloat(1))
        
    }

}
